<?php
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2018/9/26
 * Time: 13:59
 */
Include "config.php";
$response=array();
if($_SERVER["REQUEST_METHOD"]=="POST"){
    $uname=$_POST["uname"];
    $upwd=$_POST["upwd"];
    //准备sql语句
    $sql="INSERT INTO userinfo
(`u_name`,`u_pwd`,`u_mark`)
VALUES(?,?,0)";
//预查询
    $res=$link->prepare($sql);
    //绑定数据
    $res->bind_param("ss",$uname,$upwd);
    //执行sql语句
    $res->execute();
    //判断
    if($res->affected_rows>=1){
        $response["state"]=1;
        $response["msg"]="注册成功";
        print_r(json_encode($response));
    }else{
        $response["state"]=0;
        $response["msg"]="注册失败";
        print_r(json_encode($response));
    }
    //管理与查询对象
    $res->close();
    //关闭链接对象
    $link->close();

}else{
    $response["state"]=-1;
    $response["msg"]="请使用post请求";
    print_r(json_encode($response));
}


